package com.gem.mapper;

import com.gem.domain.CompanyContact;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: 玲
 * @Description: 企业联系人接口
 * @create 2019-10-24 20:52
 * @Modified By:
 */
@Mapper
public interface CompanyContactMapper {

    //查询每个企业下的联系人
    @Select("select * from company_contact where co_contact_company_id = #{coContactCompanyId} and co_contact_status > 0")
    List<CompanyContact> findAll(Integer coContactCompanyId);

    //查询所有企业联系人
    @Select("select * from company_contact where co_contact_status > 0")
    List<CompanyContact> findAllCon();

    //保存联系人信息
    Integer save(CompanyContact companyContact);

    //更新联系人信息
    Integer update(CompanyContact companyContact);

    //根据id伪删除联系人信息
    @Update("update company_contact set co_contact_status = -1 where co_contact_id = #{co_contact_id}")
    Integer deleteById(Integer coContactId);

    //伪删除所选联系人
    Integer deleteAll(int[] coContactIds);

    //根据id查询联系人
    @Select("select * from company_contact where co_contact_id = #{coContactId} and co_contact_status > 0")
    CompanyContact findById(Integer coContactId);

    //根据名字查询联系人
    @Select("SELECT * FROM company_contact WHERE co_contact_name = #{coContactName}")
    CompanyContact selectConByName(String coContactName);

    //查询每个渠道专员下的联系人
    @Select("select * from company_contact where co_contact_company_id = #{coContactCompanyId} and co_contact_writer_id = #{uid} and co_contact_status > 0")
    List<CompanyContact> findAllByUid(@Param("coContactCompanyId") Integer coContactCompanyId, @Param("uid") Integer uid);
}
